package com.example.wangyuyuan.androidframe.data.api;

import com.example.wangyuyuan.androidframe.mvp.base.BaseResponse;
import com.example.wangyuyuan.androidframe.mvp.base.ErrorBean;
import com.example.wangyuyuan.androidframe.mvp.entitry.LoginUserinfo;

import java.util.concurrent.TimeUnit;

import io.rx_cache.DynamicKey;
import io.rx_cache.EvictDynamicKey;
import io.rx_cache.LifeCache;
import io.rx_cache.Reply;
import rx.Observable;

/**
 * Created by wangyuyuan on 2017/5/9.
 * 缓存API接口
 *
 * @LifeCache设置缓存过期时间. 如果没有设置@LifeCache , 数据将被永久缓存理除非你使用了 EvictProvider, EvictDynamicKey or EvictDynamicKeyGroup .
 * EvictProvider可以明确地清理清理所有缓存数据.
 * EvictDynamicKey可以明确地清理指定的数据 DynamicKey.
 * EvictDynamicKeyGroup 允许明确地清理一组特定的数据. DynamicKeyGroup.
 * DynamicKey驱逐与一个特定的键使用EvictDynamicKey相关的数据。比如分页，排序或筛选要求
 * DynamicKeyGroup。驱逐一组与key关联的数据，使用EvictDynamicKeyGroup。比如分页，排序或筛选要求
 */

public interface CacheProviders {

    @LifeCache(duration = 1, timeUnit = TimeUnit.SECONDS)
    Observable<Reply<BaseResponse<ErrorBean>>> queryNewVersion(Observable<BaseResponse<ErrorBean>> observable, DynamicKey dynamicKey, EvictDynamicKey evictDynamicKey);

    //    登陆
    @LifeCache(duration = 1, timeUnit = TimeUnit.SECONDS)
    Observable<Reply<LoginUserinfo>> login(Observable<LoginUserinfo> observable, DynamicKey dynamicKey, EvictDynamicKey evictDynamicKey);

}
